// pages/my/aijiujilu/aijiujilu.js
Page({
    /**
     * 页面的初始数据
     */
    data: {
        // defaultDate: [1718467200000, 1718380800000, 1718280800000],
        defaultDate: [],
        jindu: 65, // 进度
        total: 0,
        currentValue: 0,
        youjihua: false,
        isJinrijihuawancheng: false,
        formatter(day) {
            const month = day.date.getMonth() + 1;
            const date = day.date.getDate();
            if (day.date == new Date()) {
                day.text = '今天';
            }
            return day;
        },
    },

    clickKaishiaijiu() {
        wx.navigateTo({
            url: '../../../template/jihua/jihua',
        })
    },

    getaijiujilu() {
        const jihualistData = wx.getStorageSync('jihualistData') || []
        console.log('getaijiujilu:', jihualistData)
            const data2 = jihualistData
            const timelist = data2.map((o) => o.timestr)
            timelist.unshift(new Date().getTime())
            this.setData({
                defaultDate: timelist
            })
    },

    /**
     * 生命周期函数--监听页面加载
     */
    onLoad(options) {
        const jihualistData = wx.getStorageSync('jihualistData') || []
        const jhcurrentItem = wx.getStorageSync('jhcurrentItem')
        const currentValue = wx.getStorageSync('currentValue')
        const isJinrijihuawancheng = wx.getStorageSync('isJinrijihuawancheng')
        this.getaijiujilu();
        let currentValueNum = 1
        jihualistData.forEach((o, i) => {
            if (o.id == currentValue.id) {
                currentValueNum = i + 1
            }
        })
        this.setData({
            youjihua: jhcurrentItem ? true : false,
            isJinrijihuawancheng: isJinrijihuawancheng,
            total: jihualistData.length,
            currentValue,
            jindu: jihualistData.length ? ((currentValueNum / jihualistData.length) * 100).toFixed(0) : 0
        })
    },

    /**
     * 生命周期函数--监听页面初次渲染完成
     */
    onReady() {

    },

    /**
     * 生命周期函数--监听页面显示
     */
    onShow() {

    },

    /**
     * 生命周期函数--监听页面隐藏
     */
    onHide() {

    },

    /**
     * 生命周期函数--监听页面卸载
     */
    onUnload() {

    },

    /**
     * 页面相关事件处理函数--监听用户下拉动作
     */
    onPullDownRefresh() {

    },

    /**
     * 页面上拉触底事件的处理函数
     */
    onReachBottom() {

    },

    /**
     * 用户点击右上角分享
     */
    onShareAppMessage() {

    }
})